<template>
  <div class="app-container">

    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="项目名称" prop="prjName">
        <el-input v-model="queryParams.prjName" placeholder="请输入关键字" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="标准类型" prop="standardType">
        <el-select v-model="queryParams.standardType" placeholder="请选择" clearable size="small">
          <el-option v-for="dict in typeStandardLevelOptions" :key="dict.dictLabel" :label="dict.dictLabel" :value="dict.dictLabel" />
        </el-select>
      </el-form-item>

      <el-form-item label="审核单位" prop="auditCompany">
        <el-select v-model="queryParams.auditCompany" placeholder="请选择" clearable size="small">
          <el-option v-for="dict in typeStandardUnitOptions" :key="dict.dictLabel" :label="dict.dictLabel" :value="dict.dictLabel" />
        </el-select>
      </el-form-item>

      <el-form-item label="经办人" prop="operatorName">
        <el-input v-model="queryParams.operatorName" placeholder="请输入关键字" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="编制单位" prop="editCompany">
        <el-input v-model="queryParams.editCompany" placeholder="请输入关键字" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="办理人" prop="currOptName">
        <el-input v-model="queryParams.currOptName" placeholder="请输入关键字" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>

      <el-form-item label="开始时间">
        <el-date-picker v-model="dateRange" size="small" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
          range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary"  size="mini" @click="handleQuery">搜索</el-button>
        <el-button size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="20" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['standard:notice:add']">新增
        </el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['standard:notice:edit']">修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['standard:notice:remove']">删除
        </el-button>
      </el-col> -->

      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['standard:notice:export']">导出</el-button>
      </el-col>

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="mList" @selection-change="handleSelectionChange">
      <!-- <el-table-column type="selection" width="55" align="left" /> -->
      <el-table-column label="项目名称" align="left" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span class="link-type" @click="handleView(scope.row)">{{ scope.row.projectName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="标准规范层次" align="left" prop="stdTp"></el-table-column>
      <el-table-column label="审核单位" align="left" prop="stdUnit"></el-table-column>
      <el-table-column label="编制单位" align="left" prop="eunit" width="200" />
      <el-table-column label="开始时间" align="left" prop="planTime" width="200">
        <template slot-scope="scope">
          <span>{{ parseDate(scope.row.planTime, '') }}</span>
        </template>
      </el-table-column>

      <el-table-column label="状态" align="left" prop="status">
        <template slot-scope="scope">
          <span>{{scope.row.statusCn}}</span>
          <el-progress :percentage="scope.row.status" status="success" v-if="scope.row.wStatus=='3'"></el-progress>
          <el-progress :percentage="scope.row.status" v-if="scope.row.wStatus=='2'"></el-progress>
          <el-progress :percentage="scope.row.status" status="exception" v-if="scope.row.wStatus=='1'"></el-progress>
          <el-progress :percentage="scope.row.status" status="warning" v-if="scope.row.wStatus=='0'"></el-progress>
        </template>
      </el-table-column>


      <el-table-column label="操作" align="left" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">详情</el-button>
          <!--已提交审核的可以办理-->
          <el-button size="mini" type="text" icon="el-icon-edit-outline" v-if="((scope.row.flowToName.split(',').indexOf(userName)>=0)||roles.indexOf('admin')!=-1) && scope.row.wStatus!='3'"
            @click="handleTransact(scope.row)" v-hasPermi="['standard:notice:transact']">办理
          </el-button>
          <!--退回或未提交审核的可以修改-->
          <el-button size="mini" type="text" icon="el-icon-edit" v-if="((scope.row.wStatus=='0' || scope.row.wStatus=='1') && scope.row.flowToName.split(',').indexOf(userName)>=0)||roles.indexOf('admin')!=-1"
            @click="handleUpdate(scope.row)" v-hasPermi="['standard:notice:edit']">修改
          </el-button>
          <!--未提交审核的可以删除-->
          <el-button size="mini" type="text" icon="el-icon-delete" v-if="(scope.row.wStatus=='0' && scope.row.flowToName.split(',').indexOf(userName)>=0)||roles.indexOf('admin')!=-1"
            @click="handleDelete(scope.row)" v-hasPermi="['standard:notice:remove']">删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改立项通知（市监）对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1080px" append-to-body>

      <el-row :gutter="20" v-if="steps < '2'">
        <el-col :span="22" :offset="1">
          <el-steps :active="steps" align-center>
            <el-step title="选择标准规范层次"></el-step>
            <el-step title="选择审核单位"></el-step>
            <el-step title="开始表单填写"></el-step>
          </el-steps>
        </el-col>
      </el-row>

      <el-form ref="form" :model="form" :rules="rules" style="font-size: 18px;">
        <el-row :gutter="20" style="margin-top: 20px;" v-if="steps == '0'">
          <el-form-item label-width="0px;">
            <el-col :span="24" align="left">
              <span style="font-size: 18px;">标准规范层次：&nbsp;&nbsp;</span>
              <el-radio-group v-model="form.stdTp" class="radio-group-text">
                <el-radio v-for="dict in typeStandardLevelOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"
                >{{dict.dictLabel}}</el-radio>
              </el-radio-group>
            </el-col>
          </el-form-item>
        </el-row>

        <el-row :gutter="20" style="margin-top: 20px;" v-if="steps == '1'">
          <el-form-item label-width="0px;">
            <el-col :span="24" align="left">
              <span style="font-size: 18px;">标准规范立项单位：&nbsp;&nbsp;</span>
              <el-radio-group v-model="form.stdUnit" class="radio-group-text">
                <el-radio v-for="dict in typeStandardUnitOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue">{{dict.dictLabel}}</el-radio>
              </el-radio-group>
            </el-col>
          </el-form-item>
        </el-row>
      </el-form>

      <el-row :gutter="20" style="font-size: 18px;" v-if="steps < '2'">
        <el-col :span="24" align="left">
          <el-button @click="back" v-if="steps > '0'">上一步</el-button>
          <el-button @click="next">下一步</el-button>
        </el-col>
      </el-row>

      <el-divider v-if="steps < '2'"></el-divider>

      <div v-if="steps < '2'">
        <b>说明</b>
        <p><b>标准规范层次</b></p>
        <span>层次：国际标准、国家标准、行业标准、地方标准、团体标准、指南指引。</span>
        <!-- <span class="text-danger">(团体标准和指南指引无需立项，起草后，通过部门审核即可)</span> -->
        <p><b>地方标准</b></p>
        <span>深圳市地方标准含广东省地方标准、深圳特区技术规范、深圳市标准化指导性技术文件、深圳市水务工程建设标准等。</span>
      </div>

      <el-card class="box-card" v-if="steps == '2' || steps == '3'">
        <div slot="header" class="clearfix">
          <span style="font-size: 16px;font-weight: 600;">项目基础信息</span>
        </div>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-col :span="12">
            <el-form-item label="项目名称" prop="projectName">
              <el-input v-model="form.projectName" placeholder="项目名称" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目关键词" prop="keyword">
              <el-input v-model="form.keyword" placeholder="项目关键词，多个关键词用，隔开" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="专业门类选择" prop="majorValue">
              <el-cascader style="width: 380px;" v-model='majorValue' :options="majorOptions" @change="handleChangeMajor"></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="功能序列选择" prop="functionValue">
              <el-cascader style="width: 380px;" v-model='functionValue' :options="functionOptions" @change="handleChangeFunction"></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="标准性质" prop="standardNature">
              <el-select style="width: 380px;" v-model="form.standardNature" placeholder="请选择">
                <el-option v-for="dict in typeStandardNatureOptions" :key="dict.dictValue" :label="dict.dictLabel"
                  :value="dict.dictValue" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="标准状态" prop="standardStatus">
              <el-select style="width: 380px;" v-model="form.standardStatus" placeholder="请选择">
                <el-option v-for="dict in typeStandardStatusOptions" :key="dict.dictValue" :label="dict.dictLabel"
                  :value="dict.dictValue" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-form>
      </el-card>

      <el-card class="box-card" style="margin-top: 20px;" v-if="steps == '2'">
        <div slot="header" class="clearfix">
          <span style="font-size: 16px;font-weight: 600;">市场监管局标准规范立项信息</span>
        </div>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="制定或修订" prop="tp">
                <el-radio-group v-model="form.tp" size="small">
                  <el-radio-button label="制定"></el-radio-button>
                  <el-radio-button label="修订"></el-radio-button>
                </el-radio-group>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="被修订标准号" prop="standardNo">
                <el-input v-model="form.standardNo" placeholder="被修订标准号开" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="项目承担单位" prop="hostUnit">
                <el-input v-model="form.hostUnit" placeholder="项目承担单位" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="计划完成时间" prop="pctm">
                <el-date-picker v-model="form.pctm" type="date" placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="项目负责人" prop="pi">
                <el-input v-model="form.pi" placeholder="项目负责人" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="职务" prop="post">
                <el-input v-model="form.post" placeholder="职务" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="电话" prop="tel">
                <el-input v-model="form.tel" placeholder="电话" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="电子邮件" prop="email">
                <el-input v-model="form.email" placeholder="电子邮件" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="参与起草单位" prop="partUnit">
                <el-input v-model="form.partUnit" placeholder="参与起草单位名称" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="失效时间" prop="expire">
                <el-date-picker v-model="form.expire" type="date" placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>

          <el-col :span="24">
            <h4>>>>主要起草人（前五位，按在起草工作中的贡献度排名）</h4>
          </el-col>
          <el-table :data="tableData" style="width: 100%" border>
            <el-table-column prop="dname" label="姓名" width="180">
            </el-table-column>
            <el-table-column prop="dunit" label="工作单位" width="180">
            </el-table-column>
            <el-table-column prop="dpost" label="职务职称">
            </el-table-column>
            <el-table-column prop="dprogress" label="专业">
            </el-table-column>
            <el-table-column prop="divide" label="项目分工">
            </el-table-column>
          </el-table>
          <el-col :span="24">
            <h4>>>>目的、意义及必要性</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.goalDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-col :span="24">
            <h4>>>>国内外情况简要说明</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.infosDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-col :span="24">
            <h4>>>>范围和主要技术内容</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.techDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-col :span="24">
            <h4>>>>可行性分析</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.analysisDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-col :span="24">
            <h4>>>>是否涉及专利等知识产权问题</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.propertyDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>

      <el-card class="box-card" style="margin-top: 20px;" v-if="steps == '2'">
        <div slot="header" class="clearfix">
          <span style="font-size: 16px;font-weight: 600;">项目承担单位意见</span>
        </div>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px" v-if="steps == '2'">
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.hostUnitOpinion" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>

      <el-card class="box-card" style="margin-top: 20px;" v-if="steps == '2'">
        <div slot="header" class="clearfix">
          <span style="font-size: 16px;font-weight: 600;">行政主管部门意见</span>
        </div>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px" v-if="steps == '2'">
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.authUnitOpinion" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>

      <el-card class="box-card" style="margin-top: 20px;" v-if="steps == '3'">

        <div slot="header" class="clearfix">
          <span style="font-size: 16px;font-weight: 600;">市住建局标准规范立项信息</span>
        </div>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="项目英文名称" prop="enName">
                <el-input v-model="form.enName" placeholder="项目英文名称" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="制定或修订" prop="tp">
                <el-radio-group v-model="form.tp" size="small">
                  <el-radio-button label="制定"></el-radio-button>
                  <el-radio-button label="修订"></el-radio-button>
                </el-radio-group>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="被修订标准号" prop="standardNo">
                <el-input v-model="form.standardNo" placeholder="被修订标准号" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="项目主编单位" prop="hostUnit">
                <el-input v-model="form.hostUnit" placeholder="项目主编(申报)单位" />
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item label="主编单位资格条件情况说明" prop="hostUnitDesc">
                <el-input v-model="form.hostUnitDesc" type="textarea" rows="3" placeholder="（含主编或参编的本市在编工程建设标准制修订项目计划进度完成情况，若有）"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item label="参编单位" prop="partUnit">
                <el-input v-model="form.partUnit" placeholder="参编单位" />
              </el-form-item>
            </el-col>

            <el-col :span="24" v-if="form.tp == '修订'">
              <el-form-item label="申报单位是" prop="isHostUnit">
                <el-tooltip class="item" effect="dark" content="修订项目填写" placement="right">
                  <el-radio-group v-model="form.isHostUnit">
                    <el-radio v-for="dict in stdDeclareUnitOptions" :key="dict.dictValue" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
                  </el-radio-group>
                </el-tooltip>
              </el-form-item>
            </el-col>

            <el-col :span="24" v-if="form.isHostUnit == '1' || form.isHostUnit == '2'">
              <el-form-item label="原主编单位意见" prop="exOpinion">
                <el-input v-model="form.exOpinion" type="textarea" placeholder="(若非原主编单位)"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="计划完成时间" prop="pctm">
                <el-date-picker v-model="form.pctm" type="date" placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="项目负责人" prop="pi">
                <el-input v-model="form.pi" placeholder="项目负责人" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="职务" prop="post">
                <el-input v-model="form.post" placeholder="职务" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="电话" prop="tel">
                <el-input v-model="form.tel" placeholder="电话" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="失效时间" prop="expire">
                <el-date-picker v-model="form.expire" type="date" placeholder="选择日期">
                </el-date-picker>
              </el-form-item>
            </el-col>

          </el-row>

          <el-col :span="24">
            <h4>>>>有无国家、本省本市法律法规、规范、政策和重点工作部署相关依据的情况说明</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.lawDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-col :span="24">
            <h4>>>>目的、意义及必要性</h4>
          </el-col>

          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.goalDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-col :span="24">
            <h4>>>>有无相关国家标准、行业标准、地方标准情况说明</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.stdDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-col :span="24">
            <h4>>>>有无团体标准、本企业编制的企业标准或本市政府发布的技术性指导文件的情况说明</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.techDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-col :span="24">
            <h4>>>>与国内相关标准对标情况的综合说明（含港澳台地区，可将香港等粤港澳大湾区及国内相关重点城市或地区作为对标重点）</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.countryDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-col :span="24">
            <h4>>>>与国际相关标准对标情况的综合说明（可将欧洲、英国、日本、新加坡等国家和地区作为对标重点，但不限于上述国家和地区）</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.foreignDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-col :span="24">
            <h4>>>>对标或借鉴的国际、国外或区域性（含港澳台地区和国内重点城市）先进标准名称、编号清单</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.foreignStdList" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-col :span="24">
            <h4>>>>涵盖范围和主要内容说明</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.infosDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-col :span="24">
            <h4>>>>涉及的科研成果鉴定、验证或认可情况说明</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.achievementDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-col :span="24">
            <h4>>>>是否涉及专利相关事项说明</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.propertyDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-col :span="24">
            <h4>>>>先进性、创新性和因地制宜等情况说明</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.advanceDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row>
            <el-col :span="24">
              <el-form-item label="自评价(可多选)" prop="selfEvla">
                <el-checkbox-group v-model="selfEvlaOpt" @change="handleCheckedSelfEvla">
                  <el-checkbox label="填补本市空白">填补本市空白</el-checkbox>
                  <el-checkbox label="填补国内空白">填补国内空白（不含港澳台地区）</el-checkbox>
                  <el-checkbox label="可达到国内领先水平">可达到国内领先水平</el-checkbox>
                  <el-checkbox label="可达到国际先进水平">可达到国际先进水平</el-checkbox>
                </el-checkbox-group>
              </el-form-item>
            </el-col>
          </el-row>

          <el-col :span="24">
            <h4>>>>工作经费安排情况说明</h4>
          </el-col>
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.fundsDesc" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>

      <el-card class="box-card" style="margin-top: 20px;" v-if="steps == '3'">
        <div slot="header" class="clearfix">
          <span style="font-size: 16px;font-weight: 600;">主编单位意见</span>
        </div>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.hostUnitOpinion" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>

      <el-card class="box-card" style="margin-top: 20px;" v-if="steps == '3'">
        <div slot="header" class="clearfix">
          <span style="font-size: 16px;font-weight: 600;">政府组织起草部门/业务归口行政主管部门意见</span>
        </div>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.authUnitOpinion" type="textarea" placeholder="（有自行组织专家评审的请附专家评审意见）"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>

      <el-card class="box-card" style="margin-top: 20px;" v-if="steps == '3'">
        <div slot="header" class="clearfix">
          <span style="font-size: 16px;font-weight: 600;">深圳市住房和建设局（市工程建设标准统筹管理部门）意见</span>
        </div>
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
          <el-row>
            <el-col :span="24">
              <el-form-item label-width="0px;">
                <el-input v-model="form.mainUnitOpinion" type="textarea" placeholder="请输入内容"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>

      <el-card class="box-card" style="margin-top: 20px;" v-if="optPage||viewOpt">
        <div slot="header" class="clearfix">
          <span style="font-size: 16px;font-weight: 600;">部门办理意见</span>
        </div>
        <el-form label-width="120px">
          <el-row v-for="opn in opinionList" :key="opn.id">
            <el-col :span="24">
              <el-form-item :label="opn.node">
                <el-input placeholder="" type="textarea" :value="opn.opn" readonly></el-input>
                <div style="position: absolute;right:20px;margin-top: -30px;">
                  <span>{{opn.name}}</span>
                  <span style="margin-left: 20px;">{{opn.st}}</span>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>

      <el-card class="box-card" style="margin-top: 20px;" v-if="uploadShow">
        <div slot="header" class="clearfix">
          <span style="font-size: 16px;font-weight: 600;">标准规范附件</span>
        </div>
        <el-form ref="form"  label-width="120px">
          <el-row >
            <el-col :span="12">
              <el-form-item label="标准规范附件" prop="files">
                <el-upload
                  ref="upload"
                  accept=".pdf,.doc,.docx"
                  :headers="upload.headers"
                  action="#"
                  :disabled="optPage"
                  :on-change="handleCheckFile"
                  :on-preview="handleViewFile"
                  :on-remove="handleRemoveFile"
                  :http-request="requestUpload"
                  :before-upload="beforeUpload"
                  :before-remove="beforeRemoveFile"
                  :auto-upload="false"
                  :file-list="fileList">
                  <el-button size="small" icon="el-icon-upload2" :disabled="optPage">点击上传</el-button>
                  <div class="el-upload__tip" slot="tip" >提示：只能上传word/pdf文件，且不超过20M！</div>
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>



      <div slot="footer" class="dialog-footer" v-if="(steps == '2' || steps == '3') && !viewOpt ">
        <!-- 开始办理 -->
        <!-- <el-button @click="back" v-if=" lastStep && !optPage " >上一步</el-button> -->
        <!-- 先保存，再由经办人开启流程
        <el-button @click="handleFlowTo" v-if="!optPage">提交部门审核</el-button> -->
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="submitForm" v-if="!optPage">保 存</el-button>
        <el-button type="primary" @click="handleOpinion" v-if="optPage">开始办理</el-button>
      </div>

      <!-- 开始办理对话框 -->
      <el-dialog title="开始办理" :visible.sync="openOpt" width="600px" append-to-body>

        <el-form ref="formOpt" :model="formOpt" label-width="100px">
          <el-row>
            <el-col :span="16">
              <el-form-item label="办理人意见">
                <el-input v-model="myOpinion" type="textarea" rows="5" placeholder=""></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8" class="word_hui">
              <el-button size="small" style="margin-top: 3px;margin-left: 10px;" @click="inputOpinion">同意。</el-button>
              <el-button size="small" style="margin-top: 3px;" @click="inputOpinion">已阅。</el-button>
              <el-button size="small" style="margin-top: 3px;" @click="inputOpinion">退回。</el-button>
              <el-button size="small" style="margin-top: 3px;" @click="inputOpinion">抓紧办理。</el-button>
              <el-button size="small" style="margin-top: 3px;" @click="inputOpinion">重新修改。</el-button>
            </el-col>
          </el-row>
          <!-- <el-row>
            <el-col :span="24">
              <el-form-item label="流程提交至">
                <el-select v-model="submitTo" value-key="dictValue" placeholder="请选择" @change="handleCheckedFlowTo">
                  <el-option v-for="dict in flowToOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row> -->

          <el-row v-if="flowToLabel!='流程结束'">
            <el-col :span="24">
              <el-form-item :label="flowToLabel">
                <el-select v-model="submitToName" value-key="userId" placeholder="请选择" ><!-- @change="handleCheckedFlowToName" 暂时没用上 -->
                  <el-option v-for="user in flowToNameOptions" :key="user.userId" :label="user.nickName" :value="user.userId" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <!-- <el-row v-show="flowToLabel=='流程结束'" >
            <el-col :span="24">
              <el-form-item label="审批处审查经办人">
                <el-select v-model="submitToJscName" value-key="userId" placeholder="请选择" @change="handleCheckedFlowToJsc">
                  <el-option v-for="user in flowToJscNameOptions" :key="user.userId" :label="user.nickName" :value="user.userId" />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row> -->


        </el-form>

        <div slot="footer" class="dialog-footer">
          <el-button @click="openOpt = false">返 回</el-button>
          <el-button type="primary" @click="submitOptForm">办理完成</el-button>
        </div>
      </el-dialog>

    </el-dialog>

  </div>
</template>

<script>

  import {
    listNotice,
    getNotice,
    delNotice,
    addNotice,
  } from '@/api/standard/notice'
  import {
    getToken
  } from "@/utils/auth";
  import {
    updateHistoryimport,
    addUploadFile,
    updateUploadFile,
    delUploadFile,
    getUploadFiles
  } from "@/api/result/storage";

  import {
    getFlow,
    selectOptions,
    selectOptionsByNames,
    saveFlow,
    listOpinion
  } from "@/api/standard/flow";

  import { listSImp } from '@/api/result/property'

  import { exportM } from "@/api/standard/m";

  import { optionSelect } from "@/api/system/dict/data";
  import { flowSelect } from "@/api/system/role";
  import store from "@/store";

  // 默认流程
  import flowToDefault from "@/utils/flowToDefault";

  export default {
    name: 'M',
    data() {
      return {
        // 遮罩层
        loading: false,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 弹出层标题
        title: '',
        // 是否显示弹出层
        open: false,
        openView: false,

        // 立项通知（市监）表格数据
        mList: [],
        tableData: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          params: null,
          prjName: null,
          processStatus: null,
          operatorName: null,
          currOptName: null,
          standardType: null,
          auditCompany: null,
          editCompany: null,
          historyImport: 1
        },
        // 日期范围
        dateRange: [],

        work: {
          todo: 8,
          done: 24,
          doing: 17,
          back: 3,
        },
        //当前步骤0,1,2,3
        steps: 0,

        //专业门类选择
        majorValue: [],
        majorOptions: [],
        //功能序列选择
        functionValue: [],
        functionOptions: [],
        // 自我评价
        selfEvlaOpt: [],
        // 类型数据字典
        typeOptions: [],
        typeStandardNatureOptions: [],
        typeStandardStatusOptions: [],
        typeStandardLevelOptions: [],
        typeStandardUnitOptions: [],
        // 申报单位
        stdDeclareUnitOptions: [],
        standardNature: null,
        standardStatus: null,
        //标准类型
        standardType: null,
        //单位
        unitType: null,
        //是否修改页面
        lastStep: true,
        openOpt: false,
        // 是否查看页面
        viewOpt: false,
        // 是否办理页面
        optPage: false,
        // 是否显示附件上传
        uploadShow: false,
        // 角色选项
        roleOptions: [],
        // 流程节点
        flowToOptions: [],
        flowToNameOptions: [],
        // 当前用户名
        userName: store.getters && store.getters.name,
        roles: store.getters && store.getters.roles,
        submitToName: null,
        submitToJscName: "",
        // 审批处经办人
        flowToJscNameOptions: [],
        myOpinion: null,
        submitTo: null, //当前选择的流程节点
        flowToLabel: null, //
        opinionList: [],
        // 默认流程节点
        defaultFlowToList: flowToDefault,

        // 表单参数
        form: {},
        // 办理表单参数
        formOpt: {},
        // 表单校验
        rules: {
          userid: [{
            required: true,
            message: '用户id不能为空',
            trigger: 'blur'
          }],
          nextNodeK: [{
            required: true,
            message: '请选择流程提交至',
            trigger: 'blur'
          }],
          nextNode: [{
            required: true,
            message: '请选择办理人',
            trigger: 'blur'
          }],
        },

        // 附件上传
        upload: {
          updateSupport: 0,
          // 设置上传的请求头部
          headers: {
            Authorization: "Bearer " + getToken()
          },
          // 上传的地址
          url: process.env.VUE_APP_BASE_API + "/standard/request/attachment"
        },
        // 上传多附件时,只执行一次
        fileIndex: 0,
        // 用作页面展示的上传文件list
        fileList: [],
        // 用作上传到后台的file参数
        uploadfileList: [],
        // 控制项目下拉是否可选
        prjSelect: false,
        // 记录附件是否发生变化
        fileChange: false,
        // 被删除的文件名称
        delFileName: null,
        // 新上传的附件数量
        countNewFile: 0,
      }
    },
    created() {
      // console.log(this.defaultFlowToList)
      // console.log(this.flowToOptions.length)

      this.getList();



      //立项通知流程状态
      this.getDicts('standard_notice_type').then(response => {
        this.typeOptions = response.data
      });
      //标准性质
      this.getDicts('standard_nature_type').then(response => {
        this.typeStandardNatureOptions = response.data
      });
      //标准状态
      this.getDicts('standard_status_type').then(response => {
        this.typeStandardStatusOptions = response.data
      });
      //专业门类选择
      optionSelect("standard_major_type").then(response => {
        this.majorOptions = this.cascaderNormalizer(response.data)
      });
      //功能序列选择
      optionSelect("standard_function_type").then(response => {
        this.functionOptions = this.cascaderNormalizer(response.data)
      });
      //标准规范立项单位
      this.getDicts("standard_project_unit").then(response => {
        this.typeStandardUnitOptions = response.data
      });
      //标准规范种类
      this.getDicts("standard_level_type").then(response => {
        this.typeStandardLevelOptions = response.data
      });
      //申报单位
      this.getDicts("standard_declare_unit").then(response => {
        this.stdDeclareUnitOptions = response.data
      });
      // 审批处经办人列表
      selectOptionsByNames(null,'审批处','经办人').then(response => {
        this.flowToJscNameOptions = response.data
        // 默认选中第一个
        if(this.flowToJscNameOptions.length>0){
          this.submitToJscName = this.flowToJscNameOptions[0].userId;
        }
      });
    },
    methods: {
      /** 查询 【历史存留标准规范入库】列表 */
      getList() {
        this.loading = true;
        listNotice(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.mList = response.rows;
          this.total = response.total;
          this.loading = false;
        })
      },

      // 获取用户信息
      getUser() {
        getUserProfile().then(response => {
          this.user = response.data;
        });
      },

      // 标准规范种类字典翻译
      stdTpFormat(row, column) {
        return this.selectDictLabel(this.typeStandardLevelOptions, row.stdTp);
      },

      // 审核单位字典翻译
      stdUnitFormat(row, column) {
        return this.selectDictLabel(this.typeStandardUnitOptions, row.stdUnit);
      },

      // 提交部门审核
      flowTo() {
        this.open = false
        this.steps = 0
        // this.lastStep = true
        this.reset()
        this.msgSuccess('提交成功')
      },

      // 取消按钮
      cancel() {
        this.open = false
        this.steps = 0
        // this.lastStep = true
        this.reset()
      },
      // 表单重置
      reset() {
        this.form = {
          nid: null,
          userid: null,
          wid: null,
          nname: null,
          eunit: null,
          pctm: null,
          expire: null,
          ld: null,
          partUnit: null,
          ldp: null,
          isHostUnit: null,
          ldu: null,
          projectName: null,
          keyword: null,
          majorValue: null,
          functionValue: null,
          standardNature: null,
          standardStatus: null,
          enName: null,
          tp: null,
          standardNo: null,
          hostUnit: null,
          planTime: null,
          pi: null,
          post: null,
          tel: null,
          email: null,
          hostUnitOpinion: null,
          authUnitOpinion: null,
          mainUnitOpinion: null,
          stdTp: '地方标准',
          exOpinion: null,
          stdUnit: null,
          goalDesc: null,
          wStatus: "0",
          infosDesc: null,
          techDesc: null,
          analysisDesc: null,
          propertyDesc: null,
          hostUnitDesc: null,
          lawDesc: null,
          stdDesc: null,
          countryDesc: null,
          foreignDesc: null,
          foreignStdList: null,
          achievementDesc: null,
          advanceDesc: null,
          fundsDesc: null,
          selfEvla: null
        }
        this.resetForm('form')

        this.viewOpt = false

        // 重置的时候,数组都要注意置空
        this.majorValue = null
        this.functionValue = null
        this.selfEvlaOpt = null
      },

      resetOptForm() {
        this.formOpt = {
          id: null,
          nid: null,
          stamp: null,
          userid: null,
          opt: null,
          ctn: null,
          res: null,
          opn: null,
          flowToUserid: null,
          flowToRoleid: null,
          flowToDeptid: null,
          currNodeK: null,
          currNode: null,
          nextNodeK: null,
          nextNode: null
        };
        this.resetForm("formOpt");
      },

      // 根据选中的角色,查找相应的用户清单
      handleCheckedFlowTo(value) {
        this.submitToName = null
        this.flowToNameOptions = []

        if (value == 'end') {
          this.flowToLabel = "流程结束"
          return false
        }

        const userid = this.formOpt.userid
        selectOptions(userid, value).then(response => {
          this.flowToNameOptions = response.data
          if (value == 'operator') { // 经办人
            this.submitToName = this.form.userid
            this.formOpt.userid = this.submitToName
          }
        });

        let obj = this.flowToOptions.find((item) => { //这里的carslist就是上面遍历的数据源
          return item.dictValue === value; //筛选出匹配数据
        });
        // console.log(obj); //obj即是选中的Option数据集合
        //获取到选中的Option数据集并进行其它操作
        this.flowToLabel = obj.dictLabel
      },

      /** 选中人员 */
      handleCheckedFlowToName(value) {
        //console.log(value)
        this.formOpt.userid = value
      },

      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1
        this.getList()
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm('queryForm')
        this.handleQuery()
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.nid)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 查看操作 */
      handleView(row) {
        //避免切换（住建/市监）时报错
        this.steps = 0
        this.reset()
        const nid = row.nid || this.ids
        getNotice(nid).then(response => {
          this.functionValue = response.data.functionValue == null ? [] : response.data.functionValue.split(",").map(
            Number);
          this.majorValue = response.data.majorValue == null ? [] : response.data.majorValue.split(",").map(Number);
          this.selfEvlaOpt = response.data.selfEvla == null ? [] : response.data.selfEvla.split(",").map(String);
          if (response.data.stdUnit == '深圳市住房和建设局') {
            this.steps = 3
          } else {
            this.steps = 2
          }
          this.form = response.data
          this.open = true
          this.optPage = false
          this.title = '查看立项通知'
          // 查看标记
          this.viewOpt = true

          //加载办理意见列表
          this.opinionInfos();
        })
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset()
        this.open = true
        this.steps = 0
        // this.lastStep = true
        this.selfEvlaOpt = []
        this.optPage = false
        this.viewOpt = false
        this.title = '新增立项通知'
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        //避免切换（住建/市监）时报错
        this.steps = 0
        this.reset()
        const nid = row.nid || this.ids
        getNotice(nid).then(response => {
          this.functionValue = response.data.functionValue == null ? [] : response.data.functionValue.split(",").map(
            Number);
          this.majorValue = response.data.majorValue == null ? [] : response.data.majorValue.split(",").map(Number);
          this.selfEvlaOpt = response.data.selfEvla == null ? [] : response.data.selfEvla.split(",").map(String);

          // this.lastStep = false
          if (response.data.stdUnit == '深圳市住房和建设局') {
            this.steps = 3
          } else {
            this.steps = 2
          }

          this.form = response.data
          this.open = true
          this.optPage = false
          this.uploadShow = true

          this.title = '修改立项通知'

          //但凡是修改，都要重新审核
          this.form.wStatus = "0"

          //加载办理意见列表
          // this.opinionInfos();
        });

      },
      // 办理按钮操作
      handleTransact(row) {
        //避免切换（住建/市监）时报错
        this.steps = 0
        this.reset()

        const nid = row.nid || this.ids
        getNotice(nid).then(response => {
          this.functionValue = response.data.functionValue == null ? [] : response.data.functionValue.split(",").map(
            Number);
          this.majorValue = response.data.majorValue == null ? [] : response.data.majorValue.split(",").map(Number);
          this.selfEvlaOpt = response.data.selfEvla == null ? [] : response.data.selfEvla.split(",").map(String);

          // this.lastStep = false
          if (response.data.stdUnit == '深圳市住房和建设局') {
            this.steps = 3
          } else {
            this.steps = 2
          }
          this.lastStep = false
          this.form = response.data
          this.open = true
          //办理页面
          this.optPage = true
          this.uploadShow = true
          this.title = '办理立项通知'

          //准备办理页面数据
          this.pageOpinion();

          //加载办理意见列表
          this.opinionInfos();

        })
      },

      // 流程记录
      opinionInfos() {
        var tableName = 'tb_nop_m'
        listOpinion(this.form.nid, tableName).then(response => {
          // console.log(response.data)
          this.opinionList = response.data
        });
      },

      // 加载办理页面表单信息
      pageOpinion() {
        // 重置开始办理表单（写在这里方便记录未完成的意见）
        this.myOpinion = ""
        this.submitTo = ""
        this.submitToName = ""
        this.flowToLabel = ""

        // 根据部门名称,从字典查询配置好的流程
        this.getDictsByName(this.form.eunit).then(response => {
          this.flowToOptions = response.data
          if (this.flowToOptions.length == 0) {
            this.flowToOptions = this.defaultFlowToList
          }
        });

        // 根据wid获取流程信息，并设置默认流程节点+人
        const id = this.form.wid
        getFlow(id).then(response => {
          this.formOpt = response.data

          // 根据角色+部门获取人员列表
          const nextNodeK = this.formOpt.nextNodeK
          // 默认选择中流程
          this.submitTo = nextNodeK
          this.flowToLabel = "流程结束"
          const userid = this.formOpt.userid
          selectOptions(userid, nextNodeK).then(response => {
            this.flowToNameOptions = response.data
          });

        });
      },

      // 开始办理
      handleOpinion() {
        this.openOpt = true;
      },

      /** 办理完成提交按钮 */
      submitOptForm() {
        // 遇到bug Textarea无法用validate，这个表单验证漏洞百出，屌用都没有，只能自己写
        if (this.myOpinion == null || this.myOpinion == '') {
          this.$message.error('办理人意见不能为空');
          return false
        } else {
          // 设置当前节点办理意见
          this.formOpt.opn = this.myOpinion;
        }
        if (this.submitTo == null || this.submitTo == '') {
          this.$message.error('请选择流程跳转至');
          return false
        } else {
          // 设置节点提交后的办理人角色名称+角色编码
          this.formOpt.currNodeK = this.submitTo
          this.formOpt.currNode = this.flowToLabel
        }
        if (this.flowToLabel != '流程结束' && (this.submitToName == null || this.submitToName == '')) {
          this.$message.error('办理人不能为空');
          return false
        } else {
          // 设置节点提交后办理人ID
          this.formOpt.userid = this.submitToName
        }

        // 跳转审批处经办人
        // if(this.flowToLabel=='流程结束'){
        //   if(this.submitToJscName==null||this.submitToJscName==''){
        //     this.$message.error('审批处经办人不能为空');
        //     return false
        //   }
        //   // 赋值审批处经办人给后台
        //   this.form.tech_operator_userid = this.submitToJscName
        // }

        // 补全参数(默认值)
        this.formOpt.flowToDeptid = null
        this.formOpt.flowToUserid = null
        this.formOpt.flowToRoleid = null
        this.formOpt.nextNode = null
        this.formOpt.nextNodeK = null

        // 保存办理意见，流程跳转
        if (this.formOpt.nid != null) {
          saveFlow(this.formOpt).then(response => {
            console.log(response)
            var wid = response.wid;
            this.updateWstatus(wid)
          });
        }
      },
      //更新当前审批的W_STATUS和WID(0待办，1退回，2办理中，3流程结束)
      updateWstatus(wid) {
        this.form.wid = wid;
        // var CurrNodeK = this.formOpt.currNodeK
        // var status = this.getFlowStatus(CurrNodeK)
        var status = '0';
        this.form.wStatus = status
        if (this.form.nid != null) {
          updateHistoryimport(this.form).then(response => {
            this.msgSuccess("提交成功");
            this.open = false;
            this.openOpt = false
            this.getList();
          });
        }
      },

      /** 提交按钮 */
      submitForm() {
        this.$refs['form'].validate(valid => {
          if (valid) {
            if (this.form.nid != null) {
              updateHistoryimport(this.form).then(response => {
                this.msgSuccess('修改成功')
                this.open = false
                this.getList()
              })
            } else {
              this.form.historyImport = 1;
              // var success1 = false;
              // var success2 = false;
              addNotice(this.form).then(response => {
                this.msgSuccess('新增成功')
                this.open = false
                this.getList()
              });
              // addHistoryimport(this.form).then(response => {
              //   success2 = true;
              // });

              // if (success1 && success2) {

              // }
            }
          }
        })
      },

      /** 提交部门审核 */
      handleFlowTo() {
        //2=办理中（部门审核），不设置时默认为0
        this.form.wStatus = "2"
        this.$confirm('确认立项通知信息无误并提交部门负责人审核?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.submitForm()
        })
      },

      /** 删除按钮操作 */
      handleDelete(row) {
        const nids = row.nid || this.ids
        this.$confirm('是否确认删除立项通知编号为"' + nids + '"的数据项?', '警告', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(function() {
          return delNotice(nids)
        }).then(() => {
          this.getList()
          this.msgSuccess('删除成功')
        })
      },
      /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams
        this.$confirm('是否确认导出所有立项通知数据项?', '警告', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(function() {
          return exportM(queryParams)
        }).then(response => {
          this.download(response.msg)
        })
      },
      /** 下一步按钮操作 */
      next() {
        if (this.steps == 0 && this.form.stdTp == null) {
          this.$message.error('请选择标准规范种类');
          return false;
        }

        if (this.steps == 1 && this.form.stdUnit == null) {
          this.$message.error('请选择标准规范立项单位');
          return false;
        }

        if (this.form.stdUnit == '深圳市住房和建设局') {
          // 跳转住建局页面
          this.steps = 3;
        } else {
          if (this.steps++ > 3) this.steps = 0;
        }

      },
      back() {
        if (this.steps == 3) {
          this.steps = 1
        } else {
          if (this.steps-- < 0) this.steps = 0;
        }
      },
      skip() {
        if (this.steps++ > 3) this.steps = 3;
      },

      inputOpinion(value) {
        this.myOpinion += value.srcElement.innerText;
      },

      handleChangeMajor(value) {
        //console.log(value.length);
        var x = '';
        for (var i = 0; i < value.length; i++) {
          if (i == 0) {
            x = value[i];
          } else {
            x = x + "," + value[i];
          }
        }
        this.form.majorValue = x;
      },
      handleChangeFunction(value) {
        //console.log(value.length);
        var x = '';
        for (var i = 0; i < value.length; i++) {
          if (i == 0) {
            x = value[i];
          } else {
            x = x + "," + value[i];
          }
        }
        this.form.functionValue = x;
      },
      // 自我评价多选
      handleCheckedSelfEvla(value) {
        // console.log(value)
        var x = '';
        for (var i = 0; i < value.length; i++) {
          if (i == 0) {
            x = value[i];
          } else {
            x = x + "," + value[i];
          }
        }
        this.form.selfEvla = x;
      },
      // 跳转审批处经办人
      handleCheckedFlowToJsc(value){
        console.log(value)
      },
      // 上传预处理
      beforeUpload(file) {
        console.log("beforeUpload...")
        const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
        const whiteList = ["pdf", "doc", "docx"];
        if (whiteList.indexOf(fileSuffix) === -1) {
          this.msgError("上传文件只能是 pdf、doc、docx格式", "error");
          return false;
        }
        const isLt20M = (file.size / 1024 / 1024) * 10 < 20;
        if (!isLt20M) {
          this.msgError("上传文件大小不能超过 20MB", "error");
          return false;
        }
        console.log("- 文件大小格式符合通过...")
      },

      // 覆盖默认的上传行为（每个附件都会执行一次）
      requestUpload(value) {
        console.log("start upload...")
        let formData = new FormData();
        // 将附件循环赋值给后台参数uploadfileList[]
        this.uploadfileList[this.fileIndex++] = value.file

        if(this.countNewFile==this.uploadfileList.length){
          for(var i=0;i<this.uploadfileList.length;i++){
            formData.append("files", this.uploadfileList[i]);
          }
          // formData.append("nid", this.prjForm.nid);//项目ID
          this.form.nid = this.prjForm.nid
          formData.append("data", JSON.stringify(this.form));
          if (this.sid != null) {
            formData.append("sid", this.sid);//起草id
            console.log("- update")
            updateUploadFile(formData).then(response => {
              this.$refs.upload.clearFiles();
              this.msgSuccess("提交成功");
              this.fileList = []
              this.uploadfileList = []
              this.fileChange = false
              this.fileIndex = 0
              this.countNewFile = 0
              // this.getList()
              this.open = false
            });
          } else {
            console.log("- add")
            addUploadFile(formData).then(response => {
              this.$refs.upload.clearFiles();
              this.msgSuccess("提交成功");
              this.fileList = []
              this.fileChange = false
              this.fileIndex = 0
              this.countNewFile = 0
              this.getList()
              this.open = false
            });
          }
          console.log("- 附件上传成功！")
        }
      },
      // 选中文件，list+1
      handleCheckFile(file, fileList) {
        this.fileList = fileList
        this.fileChange = true
        // 新增1个文件
        this.countNewFile++
      },
      // 查看附件
      handleViewFile(file, fileList){
        window.open(file.url)
      },
      // 删除附件
      handleRemoveFile(file, fileList){
        // 此处是被移除的file和fileList
        // 单独写一个移除方法,fileChange只有新上传了文件才改变
        this.fileChange = false
        // 判断是否已经上传到服务器的文件
        if(file.status=='success'){
          // 被移除附件名称
          console.log("删除文件："+file.url)
          let formData = new FormData();
          formData.append("fileName", file.url);//附件名称
          delUploadFile(formData).then(response => {
            console.log(response)
          });
        }else{
          this.countNewFile--
        }
      },
      beforeRemoveFile(file, fileList) {
        if(this.optPage){
          this.msgError("办理中不能删除附件！");
          return false;
        }
        return this.$confirm(`确定移除 ${ file.name }吗，移除后不能恢复？`);
      },
      // 文件上传中处理(添加requestUpload不起作用)
      handleFileUploadProgress(event, file, fileList) {
        console.log("handleFileUploadProgress...")
      },
      // 文件上传成功处理(添加requestUpload不起作用)
      handleFileSuccess(response, file, fileList) {
        console.log("handleFileSuccess")
        this.$refs.upload.clearFiles();
        this.$alert(response.msg, "提交结果", {
          dangerouslyUseHTMLString: true
        });
        //this.getList();
      },
      // 提交上传文件
      submitFileForm() {
        console.log("提交...")
        if (this.prjForm == null || this.prjForm.nid == null) {
          this.msgError("请选择一个项目！");
          return;
        }
        if (this.fileList.length <= 0) {
          this.msgError("请至少上传一个文件！");
          return;
        }

        this.$refs["form"].validate(valid => {
          if (valid) {
            if(this.fileChange){// 附件发生变化
              // 先单独更新一下征求意见
              updateRequest(this.form);
              this.$refs.upload.submit();//调用requestUpload方法
            }else{//当附件没有变化时，仅更新对内容
              updateRequest(this.form).then(response => {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });

            }
          }
        });
      },
    }
  }
</script>

<style>
  .bg-purple {
    background: #F8F8F9;
    height: 140px;
    text-align: center;
    padding-top: 15px;
    border: 1px solid #DFE6EB;
  }

  .span-title {
    color: #909399;
  }

  .radio-group-text span {
    font-size: 18px;
  }
</style>
